<template>
  <div class="gl_contentBox gl_heightFull">
    <el-tabs v-model="activeTab" class="gl_tabs" type="card">
      <el-tab-pane label="基础信息" name="0">
        <personal-info ref="refPersonalInfo" :is-check="true" :user-data="personinfo" />
      </el-tab-pane>
      <el-tab-pane label="会员信息" name="1">
        <!-- 中跆协会员 -->
        <modMemberInfo ref="refModMemberInfo" :is-check="true" :dict="dictRoot.dict" :user-data="personinfo" form-size="mini" :hide-title="true" :hide-style="true" />
      </el-tab-pane>
      <el-tab-pane label="段位信息" name="2">
        <!-- 中跆协级位段位 -->
        <modTkwChiDan ref="refModTkwChiDan" :is-check="true" class="gl_mb_20" :dict="dictRoot" :user-data="personinfo" form-size="mini" :hide-style="true" />
        <!-- 国际台协段位 -->
        <modTkwIntDan ref="refModTkwIntDan" :is-check="true" :dict="dictRoot" :user-data="personinfo" form-size="mini" :hide-style="true" />
      </el-tab-pane>
      <el-tab-pane label="培训考试记录" name="3">
        <!-- 培训考试记录 -->
        <Record />
      </el-tab-pane>
    </el-tabs>
    <div>
      <span slot="footer" class="difooter">
        <div slot="footer" class="dialog-footer">
          <el-button size="mini" @click="close">返回</el-button>
        </div>
      </span>
    </div>
  </div>
</template>

<script>
import Record from './record.vue';
import { mapState, mapActions } from 'vuex';
import {
  api_GET_EventsManagementRegisterId
} from '@/extend/api/gameswaggerApi/app';
import {
  SiSTKWEventsManagementCreateRegisterInput } from '@/lib/form/game/swaggerForm';
import PersonalInfo from '@/components/PersonalInfo';
import modMemberInfo from '@/views/home/train/components/modMemberInfo.vue';
import modTkwChiDan from '@/views/home/train/components/modTkwChiDan.vue';
import modTkwIntDan from '@/views/home/train/components/modTkwIntDan.vue';
export default {
  components: {
    PersonalInfo,
    modMemberInfo,
    modTkwChiDan,
    modTkwIntDan,
    Record
  },
  props: {
    father: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  data() {
    return {
      activeTab: 0,
      rid: '',
      personinfo: new SiSTKWEventsManagementCreateRegisterInput(),
      createRegisterInput1: new SiSTKWEventsManagementCreateRegisterInput()
    };
  },
  computed: {
    ...mapState({
      dictRoot: state => state.dict,
      dict: state => state.dict.dict,
      cache: state => state.dict.cache,
      currentUserType: state => state.user.currentUserType,
      tags: state => state.user.tags
    })
  },
  created() {
    this.getDictByType(['district']);
    this.getDict();
    this.$parent.tabdis = false;
    this.getStudent();
  },
  methods: {
    ...mapActions({ getDict: 'dict/getDict', getDictByType: 'dict/getDictByType' }),
    getStudent() {
      return new Promise((resolve, reject) => {
        this.personInfoLoading = true;
        api_GET_EventsManagementRegisterId(
          this.$route.query.rid || this.rid
        ).then(res => {
          this.personinfo = JSON.parse(JSON.stringify(res));
          this.personInfoLoading = false;
          this.$store.dispatch('user/getSaveCurrentUserIndInfo', res);
          resolve(res);
          this.rid = '';
        }, error => {
          this.personInfoLoading = false;
          this.$message({ type: 'error', message: '获取个人信息失败！' + (error.error && error.error.message || '') });
          reject(error);
        });
      });
    },
    close() {
      this.$router.push({ name: 'CampusData', query: { type: 'studentlist' }});
    }
  }
};
</script>

<style lang="scss" scoped>
.difooter {
  display: inline-block;
  margin-top: 20px;
  margin-left: 50%;
  transform: translateX(-50%);
}
</style>
